
import {ViewChild,Component, OnInit, ElementRef,AfterViewInit} from '@angular/core';
import {Authenticate} from '../libs/authenticate';
import {BaseComponent} from '../BaseComponent';
import {Http, Response, Headers} from '@angular/http';
import {TileObject} from '../component/tile.component';
import {Router} from '@angular/router';
import {ContainerTileObject} from '../component/containerTile.component';
import {GroupContainerTile} from '../component/groupContainerTile.component';
import {Helper} from '../libs/Helper';
import {Global} from '../libs/global';
import {HTTPService} from '../libs/HTTPService';
import {HttpExt} from '../libs/HttpExt';

@Component({
    selector: 'home',
    templateUrl: "app/home/home.html"
})

export class Home extends BaseComponent implements OnInit,AfterViewInit {
    @ViewChild("grpContainerTile") private groupContainerTile: GroupContainerTile;
    private groupTiles : ContainerTileObject[];
    constructor(private element: ElementRef,  http:HttpExt,private Service:HTTPService,private router: Router) {   
        super(http);
    }
    ngOnInit() { 

    }
    public ngAfterViewInit(): void
    {
        var that = this;
        this.groupContainerTile
            .TilePress
            .subscribe(function(e:any){
                    if(e.id=="DB")
                    {
                        that.router.navigate(['/datasource']);
                    }
                });
    }

    protected competedLanguage():void{
        var that=this;
        that.groupTiles = new Array<ContainerTileObject>();
        
        var tiles = new ContainerTileObject();
        tiles.Title = this.T["Funcion"];
        tiles.tiles = new Array<TileObject>();

        var v =new  TileObject();
        v.Title =  this.T["DataSource"];
        v.Num = 26;
        v.Icon ="fa fa-database";
        v.id = "DB";
        tiles.tiles.push(v);
        
        that.groupTiles.push(tiles);
    }

    edit(){
        if(this.groupContainerTile.InEdit)
            this.groupContainerTile.EnEdit();
        else
            this.groupContainerTile.BeginEdit();
    }
} 

